/** * 头部菜单 */
<template>
  <el-menu
    class="el-menu-demo"
    mode="horizontal"
    text-color="#fff"
    active-text-color="#fff"
  >
    <el-button class="buttonimg">
      <img
        class="showimg"
        :src="collapsed ? imgsq : imgshow"
        @click="toggle(collapsed)"
      />
    </el-button>
    <el-tooltip class="item" effect="dark" content="退出" placement="top-start">
      <span
        class="el-icon-switch-button"
        style="float: right; display: inline-block; line-height: 61px; color: #fff;   padding-right: 30px;"
        @click="exit()"
      ></span>
    </el-tooltip>
    <span
      style="color: #fff; display: inline-block; margin-left: 50px; height: 52px; line-height: 61px;"
      >你好,欢迎来到鹏城测试管理后台。</span
    >
    <div
      style="float: right; display: inline-block;
      display: flex;
      height: 60px;
margin: 0 10px;
      align-items: center;
      line-height: 61px !important;
      color: #eee; padding-right: 10px;"
    >
      <el-image
        fit="cover"
        style="width: 40px;   border-radius: 50%; height: 40px;"
        :src="superImg"
      ></el-image>
    </div>
    <span
      style="float: right; display: inline-block; line-height: 61px; color: #eee; padding-right: 10px;"
    >
      {{ info.userName }}</span
    >
  </el-menu>
</template>
<script>
export default {
  name: "navcon",
  data() {
    return {
      collapsed: true,
      imgshow: require("../assets/img/show.png"),
      imgsq: require("../assets/img/sq.png"),
      user: {},
      currentTime: "",
      superImg: JSON.parse(localStorage.getItem("info")).img
    };
  },
  // 创建完毕状态(里面是操作)
  created() {
    this.user = JSON.parse(localStorage.getItem("userdata"));
    this.info = JSON.parse(localStorage.getItem("info"));
  },
  methods: {
    // 退出登录
    exit() {
      this.$confirm("退出登录, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          setTimeout(() => {
            this.$store.commit("logout", "false");
            this.$router.push({ path: "/login" });
            this.$message({
              type: "success",
              message: "已退出登录!"
            });
          }, 1000);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    },

    // 切换显示
    toggle(showtype) {
      this.collapsed = !showtype;
      this.$root.Bus.$emit("toggle", this.collapsed);
    }
  }
};
</script>
<style scoped>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
}

.el-menu-demo {
  /*background: -webkit-linear-gradient(left, #14171a, rgb(62, 62, 75));*/
  background: -webkit-linear-gradient(
    left,
    #111,
    #222222,
    #111,
    #333333,
    #333333,
    #222222,
    #111
  );
  box-shadow: 3px 3px 6px rgba(123, 117, 117, 0.9);
}

.submenu {
  float: right;
}

.buttonimg {
  height: 60px;
  background-color: transparent;
  border: none;
}

.showimg {
  width: 26px;
  height: 26px;
  position: absolute;
  top: 17px;
  left: 17px;
}

.showimg:active {
  border: none;
}
</style>
